require("../css/register.less")
require("../fonts/iconfont.css")
// let inps = document.querySelectorAll('.inp');
// for (let i = 0; i < inps.length; i++) {

//     inps[i].addEventListener('blur', function (e) {
//         let reg = '';
//         if (i === 0) {
//             //定义手机号的正则
//             reg = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
//           inps[0].style.background = 'pink';

//         }else if(i===0){
//           inps[0].style.background = 'red';
//         }

// console.log(reg);
// let res = reg.test(this.value);
// if (res) {

// } else {
//     this.style.background = 'red';
//     this.style.color = "white"
// }

//     })
// }
let account = document.querySelector(".account ")
let registreAn = document.querySelector("#registreAn")
let inphaoma = document.querySelector(".inphaoma")//shu输入手机号码
let inppass = document.querySelector(".inppass")//输入密码


account.addEventListener("click", function () {
    location.href = "./advertisement.html"
})
let canvass = document.querySelector(".canvass")
let captchaCode = '' // 用这个变量保存验证码 code
// 渲染验证码
// cosnt 实例对象 = new 构造函数（大驼峰）
const captchaDrawer = new CaptchaMini({ // 配置项
    lineNum: 6
})

// 渲染验证码
captchaDrawer.draw(canvass, function (code) {
    captchaCode = code
})
const registerBtn = document.querySelector('#registreAn')
registerBtn.addEventListener('click', function () {
    // 请求注册接口
    $http.post('BASE_URL/users/add', {
        account: inphaoma.value,//获取表单的值
        password: inppass.value
    }, function (res) {
        if (res.status === 0) { // 请求成功
            registreAn.addEventListener("click",function (){
                location.href="./advertisement.html"
            })
            console.log(res)
            // 思考题：如何实现注册后的自动登录
        }
    })
    console.log(666);
   
})



